
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>Spring MVC 如何实现国际化？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>Spring MVC 如何实现国际化？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Spring MVC中，实现国际化（i18n）功能时，主要通过配置哪个核心类来作为消息资源的来源？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Spring MVC中，通过配置`ResourceBundleMessageSource`类来作为消息资源的来源，以支持多语言国际化。</div>
          </div>
          <div class="card-source">来源: 1. 配置国际化资源</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">Spring MVC国际化资源文件的标准命名格式是怎样的？请举例说明。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">资源文件的命名通常遵循`basename_languageCode_countryCode`的格式。例如：`messages.properties`（默认文件）、`messages_en.properties`（英语）和`messages_fr.properties`（法语）。</div>
          </div>
          <div class="card-source">来源: 1. 配置国际化资源</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在配置`ResourceBundleMessageSource`时，哪个属性用于指定消息资源文件的基本名称（basename）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在XML配置中使用`basename`属性，或在Java配置中使用`setBasenames`方法来指定消息资源文件的基本名称。例如，`value="messages"`。</div>
          </div>
          <div class="card-source">来源: 1. 配置国际化资源</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">文档中提到了哪两种`LocaleResolver`的实现，它们分别如何存储用户的区域信息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档中提到了两种实现：1. `SessionLocaleResolver`：将区域信息存储在用户会话（Session）中。2. `CookieLocaleResolver`：将区域信息存储在用户的Cookie中。</div>
          </div>
          <div class="card-source">来源: 4. 设置区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">哪个Spring MVC组件允许应用程序根据请求参数（如`?lang=zh`）来动态更改用户的区域设置？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`LocaleChangeInterceptor`允许通过请求参数动态更改用户的区域设置。</div>
          </div>
          <div class="card-source">来源: 4. 设置区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">如何配置`LocaleChangeInterceptor`以识别名为'lang'的请求参数来切换语言？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">首先创建一个`LocaleChangeInterceptor`的Bean，并调用其`setParamName("lang")`方法设置参数名。然后，通过`addInterceptors`方法将这个拦截器注册到应用程序中。</div>
          </div>
          <div class="card-source">来源: 4. 设置区域</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在Thymeleaf视图中，如何引用并显示一个key为'greeting'的国际化消息？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">在Thymeleaf视图中，可以使用`#{greeting}`表达式来显示国际化消息，例如：`<p th:text="#{greeting}">Hello</p>`。</div>
          </div>
          <div class="card-source">来源: 3. 使用消息资源</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">一个不带语言和国家代码的资源文件（如 `messages.properties`）在国际化中起什么作用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">它作为默认消息文件，用于存储默认语言（通常是英文）的消息内容，或者在找不到特定语言的翻译时作为后备。</div>
          </div>
          <div class="card-source">来源: 2. 创建翻译文件</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为了让用户能动态选择界面语言，Spring MVC提供了哪三个关键组件的组合？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring MVC提供了`ResourceBundleMessageSource`（用于配置和加载消息文件）、`LocaleResolver`（用于存储用户的区域设置）和`LocaleChangeInterceptor`（用于允许用户通过请求参数更改区域）的组合来支持动态国际化。</div>
          </div>
          <div class="card-source">来源: 引言及 4. 设置区域</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
